package cn.tedu.luban.order.main.consumer;

import cn.tedu.luban.order.main.service.OrderService;
import com.tedu.inn.protocol.exception.BusinessException;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = "order-complete-topic",
        consumerGroup = "order-complete-group")
public class OrderCompleteConsumer implements RocketMQListener<String> {

    @Autowired
    private OrderService orderService;

    @Override
    public void onMessage(String orderNo) {
        try {
            orderService.orderComplete(orderNo);
        } catch (BusinessException e) {
            e.printStackTrace();
        }
    }
}
